<template>
  <div class="person">
    <h2>汽车信息: 一辆{{ car.brand }}车, 价格{{ car.price }}万</h2>
    <button @click="changePrice">修改汽车价格</button>
    <button @click="changeCar">修改汽车</button>
    <br>
    <h2>人员信息: 姓名: {{ person.name }}, 年龄: {{ person.age }}</h2>
    <button @click="changePerson">修改人员</button>
    <br>
    <h2>当前求和为: {{ sum }}</h2>
    <button @click="changeSum">点我sum+1</button>
    <h2></h2>
  </div>
</template>

<script setup lang="ts" name="Person">
import {ref, reactive} from 'vue'

let car = reactive({
  brand: "奔驰",
  price: 100
})
let person = ref({
  name: "张三", age: 23
})
let sum = ref(0)

function changePrice() {
  car.price += 10
}

function changeSum() {
  sum.value += 1;
}

function changeCar() {
  Object.assign(car, {brand: '奥迪', price: 1})
}

function changePerson() {
  person.value = {name: '李四', age: 24}
}
</script>


<style scoped>
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

button {
  margin: 0 5px;
}
</style>